# -*- coding: utf-8 -*-
"""
@Time    : 2024/7/8 19:14 
@Author  : ZhangShenao 
@File    : search_engine_client.py 
@Desc    : 搜索引擎客户端
"""
from bow_search_engine import BOWSearchEngine

if __name__ == '__main__':
    # 创建搜索引擎实现
    search_engine = BOWSearchEngine()

    # 添加语料库
    for i in range(1, 6):
        search_engine.add_corpus_file(f'corpus/{i}.txt')

    # 搜索
    while True:
        query = input('Please input query: \n')
        if 'bye' == query:
            print('bye bye~')
            break

        results = search_engine.search(query)
        print(f'found {len(results)} result(s):')
        for r in results:
            print(r)
